package com.wyman.factory.support;

import com.wyman.BeanException;
import com.wyman.factory.config.BeanDefinition;

/**
 * @Author 李伟民
 * @Description DateTime 2024/11/25 01:43
 */
public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFactory{

    @Override
    protected Object createBean(String beanName, BeanDefinition beanDefinition) throws BeanException {

            Object bean;
            try {
               bean =  beanDefinition.getBeanClass().newInstance();
            } catch (InstantiationException  | IllegalAccessException e) {
                throw new RuntimeException(e);
            }

            //负责管理实例化的bean
            addSingleton(beanName,bean);

            return bean;
    }
}
